/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.mzk.kramerius.rukopisyimport;

import java.io.File;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;

/**
 *
 * @author Martin Rehanek (rehan@mzk.cz)
 */
public class CopyLog {

    private Document doc = DocumentHelper.createDocument();
    private Element rootEl = doc.addElement("copyLog");
    Element teiRootDirEl = rootEl.addElement("sourceDir");
    Element outDirEl = rootEl.addElement("outDir");
    Element transformationTableEl = rootEl.addElement("transformationTable");
    private Element copiedFiles = rootEl.addElement("copiedFiles");
    private Element missingSysnos = rootEl.addElement("missingSysnos");

    public CopyLog(File teiRootdir, File transformationTable, File outDir) {
        transformationTableEl.addText(transformationTable.getAbsolutePath());
        outDirEl.addText(outDir.getAbsolutePath());
        teiRootDirEl.addText(teiRootdir.getAbsolutePath());
    }

    public Document getDoc() {
        return doc;
    }

    void addCopiedFile(File fromFile, String signature, File toFile) {
        Element copiedEl = copiedFiles.addElement("copied");
        Element from = copiedEl.addElement("from");
        from.addText(fromFile.getAbsolutePath());
        from.addAttribute("signature", fromFile.getName());
        Element to = copiedEl.addElement("to");
        to.addText(toFile.getName());
    }

    void addMissingSysno(File file, String signature) {
        Element missingSysno = missingSysnos.addElement("missingSysno");
        missingSysno.addAttribute("signature", signature);
        missingSysno.addText(file.getAbsolutePath());
    }
}
